package xin.yangshuai.transactional01.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xin.yangshuai.transactional01.service.PropagationServiceA;

@RestController
@RequestMapping("user")
public class TestUserController {

    @Autowired
    private PropagationServiceA propagationServiceA;

    @GetMapping("requiredToRequired")
    public String requiredToRequired() {
        propagationServiceA.requiredToRequired();
        return "hello world";
    }

    @GetMapping("requiredToRequired1")
    public String requiredToRequired1() {
        propagationServiceA.requiredToRequired1();
        return "hello world";
    }

    @GetMapping("requiredToRequired2")
    public String requiredToRequired2() {
        propagationServiceA.requiredToRequired2();
        return "hello world";
    }

    @GetMapping("noToRequired")
    public String noToRequired() {
        propagationServiceA.noToRequired();
        return "hello world";
    }

    @GetMapping("requiredToSupports")
    public String requiredToSupports() {
        propagationServiceA.requiredToSupports();
        return "hello world";
    }

    @GetMapping("requiredToSupports1")
    public String requiredToSupports1() {
        propagationServiceA.requiredToSupports1();
        return "hello world";
    }

    @GetMapping("requiredToSupports2")
    public String requiredToSupports2() {
        propagationServiceA.requiredToSupports2();
        return "hello world";
    }

    @GetMapping("noToSupports")
    public String noToSupports() {
        propagationServiceA.noToSupports();
        return "hello world";
    }

    @GetMapping("requiredToMandatory")
    public String requiredToMandatory() {
        propagationServiceA.requiredToMandatory();
        return "hello world";
    }

    @GetMapping("requiredToMandatory1")
    public String requiredToMandatory1() {
        propagationServiceA.requiredToMandatory1();
        return "hello world";
    }

    @GetMapping("requiredToMandatory2")
    public String requiredToMandatory2() {
        propagationServiceA.requiredToMandatory2();
        return "hello world";
    }

    @GetMapping("noToMandatory")
    public String noToMandatory() {
        propagationServiceA.noToMandatory();
        return "hello world";
    }

    @GetMapping("requiredToRequiresNew")
    public String requiredToRequiresNew() {
        propagationServiceA.requiredToRequiresNew();
        return "hello world";
    }

    @GetMapping("requiredToRequiresNew1")
    public String requiredToRequiresNew1() {
        propagationServiceA.requiredToRequiresNew1();
        return "hello world";
    }

    @GetMapping("requiredToRequiresNew2")
    public String requiredToRequiresNew2() {
        propagationServiceA.requiredToRequiresNew2();
        return "hello world";
    }

    @GetMapping("noToRequiresNew")
    public String noToRequiresNew() {
        propagationServiceA.noToRequiresNew();
        return "hello world";
    }

    @GetMapping("requiredToNotSupported")
    public String requiredToNotSupported() {
        propagationServiceA.requiredToNotSupported();
        return "hello world";
    }

    @GetMapping("requiredToNotSupported1")
    public String requiredToNotSupported1() {
        propagationServiceA.requiredToNotSupported1();
        return "hello world";
    }

    @GetMapping("requiredToNotSupported2")
    public String requiredToNotSupported2() {
        propagationServiceA.requiredToNotSupported2();
        return "hello world";
    }

    @GetMapping("noToNotSupported")
    public String noToNotSupported() {
        propagationServiceA.noToNotSupported();
        return "hello world";
    }

    @GetMapping("requiredToNever")
    public String requiredToNever() {
        propagationServiceA.requiredToNever();
        return "hello world";
    }

    @GetMapping("requiredToNever1")
    public String requiredToNever1() {
        propagationServiceA.requiredToNever1();
        return "hello world";
    }

    @GetMapping("requiredToNever2")
    public String requiredToNever2() {
        propagationServiceA.requiredToNever2();
        return "hello world";
    }

    @GetMapping("noToNever")
    public String noToNever() {
        propagationServiceA.noToNever();
        return "hello world";
    }

    @GetMapping("requiredToNested")
    public String requiredToNested() {
        propagationServiceA.requiredToNested();
        return "hello world";
    }

    @GetMapping("requiredToNested1")
    public String requiredToNested1() {
        propagationServiceA.requiredToNested1();
        return "hello world";
    }

    @GetMapping("requiredToNested2")
    public String requiredToNested2() {
        propagationServiceA.requiredToNested2();
        return "hello world";
    }

    @GetMapping("noToNested")
    public String noToNested() {
        propagationServiceA.noToNested();
        return "hello world";
    }

    @GetMapping("requiredToNo")
    public String requiredToNo() {
        propagationServiceA.requiredToNo();
        return "hello world";
    }

    @GetMapping("requiredToNo1")
    public String requiredToNo1() {
        propagationServiceA.requiredToNo1();
        return "hello world";
    }

    @GetMapping("requiredToNo2")
    public String requiredToNo2() {
        propagationServiceA.requiredToNo2();
        return "hello world";
    }

    @GetMapping("noToNo")
    public String noToNo() {
        propagationServiceA.noToNo();
        return "hello world";
    }

    // 加入事务和嵌套事务的区别

    @GetMapping("requiredToRequired3")
    public String requiredToRequired3() {
        propagationServiceA.requiredToRequired3();
        return "hello world";
    }

    @GetMapping("requiredToRequiresNew3")
    public String requiredToRequiresNew3() {
        propagationServiceA.requiredToRequiresNew3();
        return "hello world";
    }

    @GetMapping("requiredToNested3")
    public String requiredToNested3() {
        propagationServiceA.requiredToNested3();
        return "hello world";
    }
}
